package com.qst.mapreduce.wordcount.zuoyemywc.zajiaoban;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class MyWordCountMapper extends Mapper<LongWritable, Text, Text, IntWritable> {
    @Override
    protected void map(LongWritable key, Text value, Mapper<LongWritable, Text, Text, IntWritable>.Context context) throws IOException, InterruptedException {
        System.out.println(key);
        System.out.println(value);
        String[] parts = value.toString().split(",\\s*");
        if (parts.length == 3) {
            Text outkey = new Text(parts[2]);
            IntWritable outValue = new IntWritable(1);
            context.write(outkey, outValue);

        }


    }
}